package com.changgou.goods.dao;

import com.changgou.pojo.Brand;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface BrandMapper extends Mapper<Brand> {
    @Select("SELECT " +
            "tb.* " +
            "FROM " +
            "tb_brand tb " +
            "LEFT JOIN tb_category_brand tcb ON tb.id = tcb.brand_id " +
            "LEFT JOIN tb_category tc ON tc.id = tcb.category_id  " +
            "WHERE " +
            "tc.NAME = #{name}")
    List<Brand> findBrandsByCategoryName(String name);

    @Select("SELECT ts.* FROM tb_template tt LEFT JOIN tb_spec ts ON ts.template_id = tt.id WHERE tt.name = #{name}")
    List<Brand> findBrandsByTemplateName(String name);
}
